﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmployeesAndOrders.aspx.cs"
    Inherits="EmployesTask.EmployeesAndOrders" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
</head>
<body>
    <form id="formMain" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server">
    </asp:ScriptManager>
    <h1>
        THIS IS THE FIRST TASK!
    </h1>

    <asp:UpdatePanel ID="UpdatePanelEmployees" runat="server">
        <ContentTemplate>
            <asp:GridView ID="GridViewEmployees" runat="server" DataSourceID="EntityDataSource"
                DataKeyNames="EmployeeID" AutoGenerateColumns="False" AllowSorting="True" 
                onselectedindexchanged="GridViewEmployees_SelectedIndexChanged">
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField DataField="FirstName" HeaderText="FirstName" ReadOnly="True" SortExpression="FirstName" />
                    <asp:BoundField DataField="LastName" HeaderText="LastName" ReadOnly="True" SortExpression="LastName" />
                    <asp:BoundField DataField="HomePhone" HeaderText="HomePhone" ReadOnly="True" SortExpression="HomePhone" />
                    <asp:BoundField DataField="Country" HeaderText="Country" ReadOnly="True" SortExpression="Country" />
                    <asp:BoundField DataField="BirthDate" HeaderText="BirthDate" ReadOnly="True" SortExpression="BirthDate" />
                </Columns>
            </asp:GridView>
            <asp:EntityDataSource ID="EntityDataSource" runat="server" ConnectionString="name=NorthwindEntities"
                DefaultContainerName="NorthwindEntities" EnableFlattening="False" EntitySetName="Employees"
                Select="it.[FirstName], it.[LastName], it.[HomePhone], it.[Country], it.[BirthDate], it.[EmployeeID]">
            </asp:EntityDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:UpdateProgress ID="UpdateProgressDemo" runat="server">
        <ProgressTemplate>
            <img src="ajax-loader.gif" alt="loading..." style="position:fixed; left:570px; top:187px; "/>
        </ProgressTemplate>        
    </asp:UpdateProgress>

    <asp:UpdatePanel runat="server">
        <ContentTemplate>
            <asp:GridView runat="server" DataSourceID="EntityDataSourceOrders" AutoGenerateColumns="False"
                AllowPaging="True" AllowSorting="True" 
                onpageindexchanged="Unnamed2_PageIndexChanged" 
                onpageindexchanging="Unnamed2_PageIndexChanging">
                <Columns>
                    <asp:BoundField DataField="OrderID" HeaderText="OrderID" ReadOnly="True" SortExpression="OrderID" />
                    <asp:BoundField DataField="RequiredDate" HeaderText="RequiredDate" ReadOnly="True"
                        SortExpression="RequiredDate" />
                    <asp:BoundField DataField="ShippedDate" HeaderText="ShippedDate" ReadOnly="True"
                        SortExpression="ShippedDate" />
                    <asp:BoundField DataField="ShipAddress" HeaderText="ShipAddress" ReadOnly="True"
                        SortExpression="ShipAddress" />
                    <asp:BoundField DataField="ShipName" HeaderText="ShipName" ReadOnly="True" SortExpression="ShipName" />
                </Columns>
            </asp:GridView>
            <asp:EntityDataSource ID="EntityDataSourceOrders" runat="server" ConnectionString="name=NorthwindEntities"
                DefaultContainerName="NorthwindEntities" EnableFlattening="False" EntitySetName="Orders"
                Select="it.[OrderID], it.[RequiredDate], it.[ShippedDate], it.[ShipAddress], it.[ShipName]"
                Where="it.[EmployeeID]==@empID" OrderBy="it.[OrderID]">
                <WhereParameters>
                    <asp:ControlParameter Type="Int32" ControlID="GridViewEmployees" Name="empID" />
                </WhereParameters>
            </asp:EntityDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>

    </form>
</body>
</html>
